local newgt = {}                     -- create new environment
setmetatable(newgt, {__index = _G})
test2 = newgt                         -- set environment to be name of map
--setfenv(1, newgt)

-- Audio vectors
sound_filenames = {"sound1.flac"}
music_filenames = {"happyTown.flac"}
-- Reference to the mode which this script describes
mode = {}
dialogueManager = {}
eventManager = {}

-- for test file, assume gender is female because that's the sprite I have
hero = nil

-- Load map objects, events, et cetera

function Init(m)
  mode = m;
  dialogueManager = m.getDialogueManager;
  eventManager = m.getEventManager;
  -- Add Sprites
  hero = CreateCharacter("walking_guy", 1, 20*32, 20*32);
  hero:setDirection(2);
  hero:setMoveSpeed(250);
  mode:addCharacter(hero);
  mode:setPlayerCharacter(hero);
  mode:setCamera(hero);
  createNPCs();
  addChest(200,400,0,1, 1, 0, 0);
  createTriggerAreas();
  createEvents();
  if (GlobalState:doesEventExist("story", "opening_finished") == false) then
    -- Since this is the first instance (being the test case) add hero to party
    GlobalState:addCharacter(hero);
print("no opening2!");
  end
end

function createNPCs() 
  local sprite;
  local dialogue;
  -- New NPC
end

function createEvents()
  local event = {}
end

local exit_area = {};
function createTriggerAreas()
  exit_area = OForce_Mode.TriggerArea(0.0, 768, 32, 640);
  mode:addTriggerArea(exit_area);
end

function checkTriggers()
--  local exitEvent = {};
  if (exit_area:enteredArea() == true) then
  end
end

function addChest(x, y, gold, chestID, itemID, isOpen, isHidden)
  -- If chest has an item, there will be no gold dropped.
  chest = OForce_Object.Treasure(x, y, gold, chestID, itemID, isOpen, isHidden);
  chest:setCurrentLayer(0);
  mode:addTreasure(chest);
end

function update() 
  checkTriggers();
end



map_functions = {}

